<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Cities extends Model
{
    use HasFactory;

    protected $table = "cities";

    public function children()
    {
        return $this->hasMany(Cities::class, 'pid');
    }

    public function brothers()
    {
        return $this->children();
    }

    public static function options($id)
    {
        if (!$self = static::find($id)) {
            return [];
        }
        return $self->brothers()->pluck('name', 'id');
    }
}
